home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / libs / makeflags < prev    next >
Text File  |  1996-07-15  |  5KB  |  190 lines

  1. # $Id: MakeFlags 1.1 1995/11/05 22:25:15 digulla Exp digulla $
  2. # $Log: MakeFlags $
  3. # Revision 1.1    1995/11/05  22:25:15  digulla
  4. # Initial revision
  5. #
  6.  
  7. # Options section. Specify the comiler/environment you want to use
  8. # Choose one and comment the others out
  9. CC = sc
  10. #CC = gcc
  11. #CC = dcc
  12.  
  13. ifeq "$(CC)" "sc"
  14. COMMON_CFLAGS    = NoVersion NoStkChk
  15. OPT_CFLAGS    = Optimize
  16. DEBUG_CFLAGS    = Debug Full Define DEBUG
  17. PROFILE_CFLAGS    = Define PROFILE
  18. EXTRA_CFLAGS    =
  19. INCLUDE_DIR    = IDir
  20. INCLUDES    = # User
  21. LIB_PREFIX    =
  22. LIB_SUFFIX    = .lib
  23. SYS_INCLUDES    =
  24. STD_INCLUDES    = $(INCLUDES) $(SYS_INCLUDES)
  25. DEFINES     =
  26. SYS_DEFINES    =
  27. STD_DEFINES    = $(DEFINES) $(SYS_DEFINES)
  28. AR        = join as
  29. PARENT_DIR    = /
  30. AS        = Asm
  31. endif
  32. ifeq "$(CC)" "gcc"
  33. COMMON_CFLAGS    = -msmall-code -Wall -Wpointer-arith
  34. OPT_CFLAGS    = -O2
  35. DEBUG_CFLAGS    = -gstabs # For the Barfly debugger
  36. PROFILE_CFLAGS    = -p      # If someone ever writes a profiler
  37. EXTRA_CFLAGS    =
  38. INCLUDE_DIR    = -I
  39. INCLUDES    = # User
  40. LIB_PREFIX    = lib
  41. LIB_SUFFIX    = .a
  42. SYS_INCLUDES    =
  43. STD_INCLUDES    = $(INCLUDES) $(SYS_INCLUDES)
  44. AR        = ar u
  45. PARENT_DIR    = ../
  46. AS        = A68k
  47. endif
  48. ifeq "$(CC)" "dcc"
  49. endif
  50.  
  51. # How to run certain commands
  52. RM        = delete quiet all
  53. MV        = rename
  54. CP        = copy quiet all
  55. MKDIR        = MakeDir
  56. ECHO        = echo
  57. INSTALL_PROGRAM = copy
  58. INSTALL_DATA    = copy
  59. LHA_FULL    = lha -x -a -r -e a
  60. LHA_DELTA    = lha -x -a -r -e -s a
  61.  
  62. # Things for make
  63. #   BUILD_OPTS : how to build target files. This is a set of flags:
  64. #        o - Use optimization when building target files (when
  65. #            applicable)
  66. #        g - Include debugging information
  67. #        p - Include profiling information
  68. #    Multiple flags can be specified in any order, ie. "gop" will
  69. #    enable all options. Note that for some compilers, o and g
  70. #    exclude each other.
  71. #   EXTRA_MAKEFLAGS - The contents of this variable is passed to sub-makes
  72. #   PASSMAKEFLAGS - (internal) This variable contains everything that should
  73. #    always be passed to sub-makes (additional to MAKEFLAGS)
  74. BUILD_OPTS    = g
  75. EXTRA_MAKEFLAGS =
  76. PASSMAKEFLAGS    = "TOP_DIR=$(TOP_DIR)" "EXTRA_MAKEFLAGS=$(EXTRA_MAKEFLAGS)" \
  77.           "BUILD_OPTS=$(BUILD_OPTS)"
  78.  
  79. prefix        = $(TOP_DIR)
  80. exec_prefix    = $(prefix)
  81. bindir        = $(exec_prefix)c/
  82. libdir        = $(exec_prefix)lib/
  83. includedir    = $(exec_prefix)include/
  84. docdir        = $(exec_prefix)doc/
  85. exampledir    = $(exec_prefix)examples/
  86.  
  87. # This is used as a pattern for making something in subdirs. Use it with
  88. # $(subst TARGET,all,$(SUBDIR_RULE))
  89. SUBDIR_RULE    = unset dir @@\
  90.     for dir in $(SUBDIRS) \
  91.     do \
  92.     $(ECHO) "Making TARGET in $(CURRENT_DIR)$$dir" ";" \
  93.     ( cd $$dir ";" $(MAKE) $(PASSMAKEFLAGS) \
  94.     "CURRENT_DIR=$(CURRENT_DIR)$$dir/" TARGET ) \
  95.     done
  96.  
  97. # Set flags for optimizations
  98. ifneq (,$(findstring o,$(BUILD_OPTS)x))
  99. CFLAGS_1    = $(OPT_CFLAGS)
  100. SUFFIX_1    = o
  101. else
  102. CFLAGS_1    =
  103. SUFFIX_1    =
  104. endif
  105.  
  106. # Set flags for debugging
  107. ifneq (,$(findstring g,$(BUILD_OPTS)x))
  108. CFLAGS_2    = $(DEBUG_CFLAGS)
  109. SUFFIX_2    = g
  110. else
  111. CFLAGS_2    =
  112. SUFFIX_2    =
  113. endif
  114.  
  115. # Set flags for profiling
  116. ifneq (,$(findstring p,$(BUILD_OPTS)x))
  117. CFLAGS_3    = $(PROFILE_CFLAGS)
  118. SUFFIX_3    = p
  119. else
  120. CFLAGS_3    =
  121. SUFFIX_3    =
  122. endif
  123.  
  124. OPT_SUFFIX = $(SUFFIX_1)$(SUFFIX_2)$(SUFFIX_3)
  125. ifneq "$(OPT_SUFFIX)" ""
  126. OBJDIR = obj_$(OPT_SUFFIX)
  127. else
  128. OBJDIR = obj
  129. endif
  130.  
  131. CFLAGS = $(strip $(COMMON_CFLAGS) $(EXTRA_CFLAGS) \
  132.         $(CFLAGS_1) $(CFLAGS_2) $(CFLAGS_3) \
  133.         $(DEFINES) $(INCLUDES))
  134.  
  135. # Use this at a leaf-rule as the last line so the use can see we're through
  136. define done-with-it
  137. @$(ECHO) "Done with $@ in $(CURRENT_DIR)"
  138. endef
  139.  
  140. # Use this in a Makefile where a specific rule doesn't apply
  141. define nothing-to-be-done
  142. @$(ECHO) "Nothing to be done for $@ in $(CURRENT_DIR)"
  143. endef
  144.  
  145. .PHONY : all clean dist check install
  146.  
  147. ifeq "$(CC)" "sc"
  148. CC_COMPILE = $(CC) $(CFLAGS)
  149. CC_LINK = $(CC) $(CFLAGS) Link To
  150. define run-cc
  151. $(CC) $(CFLAGS) $<
  152. -$(RM) $@
  153. $(MV) $(dir $<)$(notdir $@) $@
  154. endef
  155. endif
  156. ifeq "$(CC)" "gcc"
  157. CC_COMPILE = $(CC) $(CFLAGS) -c
  158. CC_LINK = $(CC) $(CFLAGS) -o
  159. define run-cc
  160. -$(RM) $@
  161. $(CC_COMPILE) $< -o $@
  162. endef
  163. endif
  164. ifeq "$(CC)" "dcc"
  165. CC_COMPILE = $(CC) $(CFLAGS) -c
  166. CC_LINK = $(CC) $(CFLAGS) -o
  167. define run-cc
  168. -$(RM) $@
  169. $(CC_COMPILE) $< -o $@
  170. endef
  171. endif
  172.  
  173. define do-dist
  174. @$(ECHO) "" > dist.dev
  175. $(foreach file,$(DEV_DIST_FILES),$(ECHO) "AROS/$(CURRENT_DIR)$(file)" >> dist.dev @@)
  176. $(foreach dir,$(SUBDIRS),$(ECHO) "@AROS/$(CURRENT_DIR)$(dir)/dist.dev" >> dist.dev @@)
  177. $(ECHO) "" > dist.usr
  178. $(foreach file,$(USR_DIST_FILES),$(ECHO) "AROS/$(CURRENT_DIR)$(file)" >> dist.usr @@)
  179. $(foreach dir,$(SUBDIRS),$(ECHO) "@AROS/$(CURRENT_DIR)$(dir)/dist.usr" >> dist.usr @@)
  180. endef
  181.  
  182. MAKEDEPEND = MkDepend
  183. define make-depend
  184. @if not exists $(OBJDIR) @@\
  185.     makedir $(OBJDIR) @@\
  186.  endif
  187. $(MAKEDEPEND) -f $@  -p ".c:$(OBJDIR)/%n.o $(OBJDIR)/%n.d" $< \
  188.     $(patsubst $(INCLUDE_DIR),-I,$(INCLUDES)) -I $(SRCDIR)
  189. endef
  190.